<?xml version="1.0"?>

<% idFileRedBee = SelectFile.where(:server => "RedBee").first.id%>
<% idSIT = ServiceInformationTable.where(:select_file_id => idFileRedBee)%>
<% idPLT = ProgramLocationTable.where(:select_file_id => idFileRedBee)%>
<% listOfServices = ServiceInformation.where(:service_information_table_id=>idSIT).select(:id).map{|i| i.id }%>


<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
  xmlns:o="urn:schemas-microsoft-com:office:office"
  xmlns:x="urn:schemas-microsoft-com:office:excel"
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
  xmlns:html="http://www.w3.org/TR/REC-html40">
  <Worksheet ss:Name="Sheet1">
    <Table>
      <Row>
        <Cell><Data ss:Type="String">Name</Data></Cell>
        <Cell><Data ss:Type="String">Expected Language</Data></Cell>
        <Cell><Data ss:Type="String">Name</Data></Cell>
        <Cell><Data ss:Type="String">Language</Data></Cell>
        <Cell><Data ss:Type="String">Start</Data></Cell>
        <Cell><Data ss:Type="String">End</Data></Cell>
        <Cell><Data ss:Type="String">Name</Data></Cell>
        <Cell><Data ss:Type="String">Language</Data></Cell>
        <Cell><Data ss:Type="String">Start</Data></Cell>
        <Cell><Data ss:Type="String">End</Data></Cell>
      </Row>
      
         <% for default_channel in DefaultChannel.all %>
         <Row>
      		<Cell><Data ss:Type="String"><%= default_channel.name %></Data></Cell>
      		<Cell><Data ss:Type="String"><%= default_channel.language %></Data></Cell>
      		<% si = ServiceInformation.where(:service_information_table_id=>idSIT).where(:name=>default_channel.name).first%>
      		<% if (si==nil)%>
      			<Cell><Data ss:Type="String"></Data></Cell>
      			<Cell><Data ss:Type="String"></Data></Cell>
      			<Cell><Data ss:Type="String"></Data></Cell>
      			<Cell><Data ss:Type="String"></Data></Cell>
      		<% else%>
      			<Cell><Data ss:Type="String"><%= si.name %></Data></Cell>
      			<%  listOfServices.delete(si.id) %>
      			<Cell><Data ss:Type="String"></Data></Cell>
      			<Cell><Data ss:Type="String"><%= Schedule.where(:program_location_table_id=>idPLT).where(:serviceIdRef=>si.serviceId).first.start %></Data></Cell>
      			<Cell><Data ss:Type="String"><%= Schedule.where(:program_location_table_id=>idPLT).where(:serviceIdRef=>si.serviceId).first.end  %></Data></Cell>
      		<% end%>
		    <Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      	</Row>
  		<% end %>
  		<% for serviceId in listOfServices %>
  		<Row>
  			<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"><%= ServiceInformation.find(serviceId).name %></Data></Cell>
  			<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"><%= Schedule.where(:serviceIdRef=>ServiceInformation.find(serviceId).serviceId).first.start %></Data></Cell>
      		<Cell><Data ss:Type="String"><%= Schedule.where(:serviceIdRef=>ServiceInformation.find(serviceId).serviceId).first.end  %></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
      		<Cell><Data ss:Type="String"></Data></Cell>
	     </Row>
	 	<% end %>
    </Table>
  </Worksheet>
</Workbook>